﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AAA.Meta.Chart.Data;

namespace AAA.TeeChart.Data
{
    public class DefaultDataSource : IDataSource
    {
        private Dictionary<string, BarData> _dicBarData;
        private Dictionary<string, BarDataExtra> _dicBarDataExtra;
        private List<string> _lstSeriesName;
        public DefaultDataSource()
        {
            _dicBarData = new Dictionary<string, BarData>();
            _lstSeriesName = new List<string>();
        }

        #region IDataSource Members

        public void AddBarData(string strName, BarData barData)
        {
            if (_lstSeriesName.IndexOf(strName) < 0)
                _lstSeriesName.Add(strName);

            if (_dicBarData.ContainsKey(strName))
                _dicBarData[strName] = barData;
            else
                _dicBarData.Add(strName, barData);
        }

        public BarData GetBarData(string strName)
        {
            return _dicBarData.ContainsKey(strName) ? _dicBarData[strName] : null;
        }

        public void Clear()
        {
            _dicBarData = new Dictionary<string, BarData>();
            _lstSeriesName = new List<string>();
        }

        public List<string> GetSeriesName()
        {
            return _lstSeriesName;
        }

        public void AddBarDataExtra(string strName, BarDataExtra barDataExtra)
        {
            if (_dicBarDataExtra.ContainsKey(strName))
                _dicBarDataExtra[strName] = barDataExtra;
            else
                _dicBarDataExtra.Add(strName, barDataExtra);

        }

        public BarDataExtra GetBarDataExtra(string strName)
        {
            return _dicBarDataExtra.ContainsKey(strName) ? _dicBarDataExtra[strName] : null;
        }

        #endregion
    }
}
